#ifndef CZY_LS_FIT
#define CZY_LS_FIT

namespace rmd {

#define ParaBuffer(Buffer, Row, Col) (*(Buffer + (Row) * (4 + 1) + (Col)))

class CLeastSquare {
 public:
  CLeastSquare();
  virtual ~CLeastSquare();

  int Cal(const double* bufferX, const double* bufferY, int amount, int sizeSrc,
          double* paraResK);

 private:
  int ParaDealB(double* para, int sizeSrc);
  int ParaDeal(double* para, int sizeSrc);
  int Paralimit(double* para, int sizeSrc);
  int ParalimitRow(double* para, int sizeSrc, int row);
  int ParaDealA(double* para, int sizeSrc);
  int ParaPreDealA(double* para, int sizeSrc, int size);
  int ParaPreDealB(double* para, int sizeSrc, int offset);

  int GetParaBuffer(double* para, const double* x, const double* y, int amount,
                    int sizeSrc);
};
}

#endif
